<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
</head>

<body>
<div>
    <form action="" method="post" autocomplete="off">
        <table>
            <tr>
                <td>登录名:</td>
                <td>
                    <input type="text" id="login_name" name="login_name"
                           onblur="checkLoginName()" placeholder="请填写用户名">
                    <!--                    <span style="text-decoration-color: red">*</span>-->
                </td>
                <td id="login_name_msg">
                    用户名以小写字母开头,可以包含大小写字母和数字;
                </td>
            </tr>
            <tr>
                <td>登录密码:</td>
                <td>
                    <input type="password" name="pwd" id="pwd" placeholder="请输入密码">
                </td>
            </tr>
            <tr>
                <td>确认密码:</td>
                <td>
                    <input type="password" name="qpwd" id="qpwd" placeholder="请确认密码">
                </td>
            </tr>
            <tr>
                <td>
                    <button type="button" id="tijiao">提交</button>
                </td>
            </tr>
        </table>
    </form>
</div>
<script type="text/javascript">
    function $(id) {
        return document.getElementById(id);
    }

    function checkLoginName() {
        var name = $("login_name").value;
        var reg = /^[a-z][a-zA-Z0-9]{5,11}$/;
        var msg = "× 登录名格式有误!";
        var flag = false;
        if (reg.test(name)) {
            msg = "√ ";
            flag = true;
        }
        $("login_name_msg").innerHTML = msg;
        return flag;
    }
</script>
</body>
</html>